package com.global.service;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.global.model.DataSourceX;
import com.global.model.Grid;
import com.global.model.Report;
import com.global.vo.QueryParameter;

public class ReportInstance implements Serializable {

	private static final long serialVersionUID = 1620827334292369250L;

	private Report report;
	private Grid grid;
	private DataSourceX dataSourceX;
	private Map<Integer, QueryParameter> queryParameterMap;
	private long dataRowCount;
	private List<String> displayNameList;
	
	private List<String> errorMessageList = new ArrayList<String>();
	
	/**
	 * 初始化报表实例
	 * @param grid 显示数据的Grid
	 * @param queryParameterMap 固定参数以及过滤数据参数
	 */
	public ReportInstance(Grid grid, Map<Integer, QueryParameter> queryParameterMap){
		this.grid = grid;
		this.queryParameterMap = queryParameterMap;
		
		if(grid==null){
			errorMessageList.add("Grid不能为空，否则无法查询数据");
		}else{
			this.report = grid.getReport();
			dataSourceX = grid.getDataSourceX();
		}
	}

	public Report getReport() {
		return report;
	}

	public Grid getGrid() {
		return grid;
	}

	public DataSourceX getDataSourceX() {
		return dataSourceX;
	}

	/**
	 * 返回数据的行数
	 * @return
	 */
	public long getDataRowCount() {
		return dataRowCount;
	}

	/**
	 * 返回数据的标题，按照配置顺序升序排列
	 * @return
	 */
	public List<String> getDisplayNameList() {
		return displayNameList;
	}

	public List<String> getErrorMessageList() {
		return errorMessageList;
	}	
	
	/**
	 * 返回参数（固定参数以及过滤数据参数）清单
	 * @return
	 */
	public Map<Integer, QueryParameter> getQueryParameterMap() {
		return queryParameterMap;
	}

	/**
	 * 获取数据
	 * @param queryParameterMap
	 */
	public void generateData(Map<Integer, QueryParameter> queryParameterMap){
		
	}
}
